home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-27 | 1.4 KB | 64 lines | [TEXT/CWIE] |
- //
- // C4BoxMaker.cp
- //
- // class C4BoxMaker
- // Class for constructing a QD3D model consisting of 4 boxes
- // with colored sides.
- //
- // Based on the "Start Here" sample code from Apple.
- //
- // by James Jennings
- // Started November 22, 1995
- //
-
- #include "C4BoxMaker.h"
- #include "StQ3Disposer.h"
-
- #include "CBoxMaker.h" // for making a single box
-
- void
- C4BoxMaker::Make()
- {
- CBoxMaker box; // construct a colored box
- TQ3Vector3D where;
- TQ3ShaderObject illuminationShader ;
-
- // Make a group to put it in
- mObject = ::Q3DisplayGroup_New();
- ThrowIfNil_(mObject);
-
- // Define a shading type for the group
- // and add the shader to the group
- illuminationShader = ::Q3PhongIllumination_New();
- StQ3Disposer ill(illuminationShader);
- ::Q3Group_AddObject(mObject, illuminationShader);
-
- // add the box four times
- ::Q3Vector3D_Set(&where, 0, 0, 0);
- AddObjectAt(box.Get(), &where);
-
- ::Q3Vector3D_Set(&where, 2, 0, 0);
- AddObjectAt(box.Get(), &where);
-
- ::Q3Vector3D_Set(&where, 0, 0, -2);
- AddObjectAt(box.Get(), &where);
-
- ::Q3Vector3D_Set(&where, -2, 0, 0);
- AddObjectAt(box.Get(), &where);
- }
-
- void
- C4BoxMaker::AddObjectAt(TQ3Object theObject, TQ3Vector3D *where)
- {
- TQ3TransformObject transform;
- TQ3GroupPosition pos;
-
- transform = ::Q3TranslateTransform_New(where);
- ThrowIfNil_(transform);
- StQ3Disposer trn(transform);
- pos = ::Q3Group_AddObject(mObject, transform);
- ThrowIf_(pos==0);
- pos = ::Q3Group_AddObject(mObject, theObject);
- ThrowIf_(pos==0);
- }
-